package com.zenithmind.document.pojo.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 文档统计VO
 * 
 * @author ZenithMind Team
 * @since 2025-01-09
 */
@Data
@Schema(description = "文档统计VO")
public class DocumentStatisticsVO {

    /**
     * 文档ID
     */
    @Schema(description = "文档ID")
    private String documentId;

    /**
     * 总访问次数
     */
    @Schema(description = "总访问次数")
    private Long totalViewCount;

    /**
     * 总下载次数
     */
    @Schema(description = "总下载次数")
    private Long totalDownloadCount;

    /**
     * 总收藏次数
     */
    @Schema(description = "总收藏次数")
    private Long totalFavoriteCount;

    /**
     * 今日访问次数
     */
    @Schema(description = "今日访问次数")
    private Long todayViewCount;

    /**
     * 今日下载次数
     */
    @Schema(description = "今日下载次数")
    private Long todayDownloadCount;

    /**
     * 本周访问次数
     */
    @Schema(description = "本周访问次数")
    private Long weekViewCount;

    /**
     * 本月访问次数
     */
    @Schema(description = "本月访问次数")
    private Long monthViewCount;

    /**
     * 平均评分
     */
    @Schema(description = "平均评分")
    private Double averageRating;

    /**
     * 评分次数
     */
    @Schema(description = "评分次数")
    private Long ratingCount;

    /**
     * 最后访问时间
     */
    @Schema(description = "最后访问时间")
    private LocalDateTime lastAccessTime;

    /**
     * 访问趋势数据（按日期）
     */
    @Schema(description = "访问趋势数据")
    private List<TrendData> viewTrend;

    /**
     * 下载趋势数据（按日期）
     */
    @Schema(description = "下载趋势数据")
    private List<TrendData> downloadTrend;

    /**
     * 访问设备统计
     */
    @Schema(description = "访问设备统计")
    private Map<String, Long> deviceStats;

    /**
     * 访问地区统计
     */
    @Schema(description = "访问地区统计")
    private Map<String, Long> regionStats;

    /**
     * 用户访问排行
     */
    @Schema(description = "用户访问排行")
    private List<UserAccessRank> userAccessRanks;

    /**
     * 存储统计信息
     */
    @Schema(description = "存储统计信息")
    private StorageStats storageStats;

    /**
     * 趋势数据
     */
    @Data
    @Schema(description = "趋势数据")
    public static class TrendData {
        @Schema(description = "日期")
        private String date;
        
        @Schema(description = "数值")
        private Long value;
    }

    /**
     * 用户访问排行
     */
    @Data
    @Schema(description = "用户访问排行")
    public static class UserAccessRank {
        @Schema(description = "用户ID")
        private String userId;
        
        @Schema(description = "用户名称")
        private String userName;
        
        @Schema(description = "访问次数")
        private Long accessCount;
        
        @Schema(description = "最后访问时间")
        private LocalDateTime lastAccessTime;
    }

    /**
     * 存储统计
     */
    @Data
    @Schema(description = "存储统计")
    public static class StorageStats {
        @Schema(description = "总文档数")
        private Long totalDocuments;
        
        @Schema(description = "总存储大小（字节）")
        private Long totalStorageSize;
        
        @Schema(description = "总存储大小格式化")
        private String totalStorageSizeFormatted;
        
        @Schema(description = "按类型统计")
        private Map<String, TypeStats> typeStats;
        
        @Schema(description = "按分类统计")
        private Map<String, CategoryStats> categoryStats;
    }

    /**
     * 类型统计
     */
    @Data
    @Schema(description = "类型统计")
    public static class TypeStats {
        @Schema(description = "文档数量")
        private Long count;
        
        @Schema(description = "存储大小")
        private Long size;
        
        @Schema(description = "存储大小格式化")
        private String sizeFormatted;
    }

    /**
     * 分类统计
     */
    @Data
    @Schema(description = "分类统计")
    public static class CategoryStats {
        @Schema(description = "分类名称")
        private String categoryName;
        
        @Schema(description = "文档数量")
        private Long count;
        
        @Schema(description = "存储大小")
        private Long size;
        
        @Schema(description = "存储大小格式化")
        private String sizeFormatted;
    }
}
